import { Button, Form, Input } from 'antd';
import React, { useState } from 'react';

export default function Page() {
  const [result, setResult] = useState<number>(0);
  const onSubmit = ({
    interest = 0,
    n = 0,
    pre = 0,
    time = 0
  }) => {
    const x = 100 * interest * 365 / pre / time;
    setResult(x);
  };
  return (
    <div>
      <Form
        onFinish={onSubmit}
        labelCol={{ span: 8 }}
        wrapperCol={{ span: 16 }}
        style={{ maxWidth: 600 }}>
        <Form.Item
          name="pre"
          label={'本金'}
        >
          <Input placeholder="本金"/>
        </Form.Item>
        <Form.Item
          name="time"
          label={'时间（天）'}
        >
          <Input placeholder="时间（天）"/>
        </Form.Item>
        <Form.Item
          name="interest"
          label={'利息'}
        >
          <Input placeholder="利息"/>
        </Form.Item>
        {/*<Form.Item*/}
        {/*  name="n"*/}
        {/*>*/}
        {/*  <Input placeholder="年利率"/>*/}
        {/*</Form.Item>*/}


        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
          <Button type="primary" htmlType="submit">
            计算
          </Button>
        </Form.Item>
      </Form>
      年利率：{result}
    </div>
  );
}
